<div class="container-fluid">
	<div id="pad-wrapper">
		<!-- products table-->
		<!-- the script for the toggle all checkboxes from header is located in js/theme.js -->
		<div class="table-wrapper products-table section">
			<div class="row-fluid head">
				<div class="span12">
					<h4>普通商品订单管理</h4>
				</div>
			</div>


			<form action="" method="get" name="search">
				<div class="row-fluid filter-block">
					<!--
					<div class="pull-left">
						<a class="btn-flat success" onclick="document.forms['batch'].submit();">批量通过</a>
					</div> -->
					<div class="pull-right">
                                                <input type="hidden" id="tag" name="tag" value="1">
						下单时间：
						<input type="text" style="cursor: default;margin-right:0" onclick="WdatePicker()" readonly="readonly" class="search" name="start_time" value="<?php echo $start_time?>"></input>
						-
						<input type="text" style="cursor: default;margin-right:20px" onclick="WdatePicker()" readonly="readonly" class="search" name="end_time" value="<?php echo $end_time?>"></input>
						支付时间：
						<input type="text" style="cursor: default;margin-right:0" onclick="WdatePicker()" readonly="readonly" class="search" name="pay_start_time" value="<?php echo $pay_start_time?>"></input>
						-
						<input type="text" style="cursor: default;margin-right:20px" onclick="WdatePicker()" readonly="readonly" class="search" name="pay_end_time" value="<?php echo $pay_end_time?>"></input>
						订单状态：
						<select name="order_status"  style="cursor: default;margin-right:20px" class="search">
							<option value ="0">所有</option>
							<?php
							foreach($arrStatus as $key => $value)
							{
								if($order_status == $value['order_status_id']){
									echo "<option value =" . $value['order_status_id'] ."  selected = \"selected\">".$value['order_status_name']  ."</option>";
								}else{
									echo "<option value =" . $value['order_status_id'] .">".$value['order_status_name']  ."</option>";
								}
							}
							?>
						</select>
						手机号：
						<input type="text" name="mobile" class="search" value="<?php echo $mobile?>"></input>
                                                昵称：
						<input type="text" name="nickname" class="search" value="<?php echo $nickname?>"></input>
                                                收货人姓名：
						<input type="text" name="addressee" class="search" value="<?php echo $addressee?>"></input>
						<a class="btn-flat success" onclick="document.forms['search'].submit();">查询</a>
                                                <a class="btn-flat success" id='daochu'>导出</a>
					</div>
				</div>
			</form>

			<div class="row-fluid">
				<table class="table table-hover">
					<thead>
					<tr>
						<!-- <th class="span3"><input type="checkbox" /> 头像</th> -->
						<th class="span1"><span class="line"></span>订单号</th>
						<th class="span3 clickable_time"><span class="line"></span>下单时间<span class="<?php
							if(!isset($_GET['sort_time'])){
								echo 'icon icon-chevron-down';
							} elseif($_GET['sort_time'] == 'asc') {
								echo 'icon icon-chevron-up';
							}elseif($_GET['sort_time'] == 'desc'){
								echo 'icon icon-chevron-down';
							}else{
								echo 'icon icon-chevron-down';
							}
							?>"></span></th>
						<th class="span3 clickable_pay_stime"><span class="line"></span>支付时间<span class="<?php
							if(!isset($_GET['sort_pay_time'])){
								echo 'icon icon-chevron-down';
							} elseif($_GET['sort_pay_time'] == 'asc') {
								echo 'icon icon-chevron-up';
							}elseif($_GET['sort_pay_time'] == 'desc'){
								echo 'icon icon-chevron-down';
							}else{
								echo 'icon icon-chevron-down';
							}
							?>"></span></th>
						<th class="span2"><span class="line"></span>购买人手机号</th>
                                                <th class="span2"><span class="line"></span>昵称</th>
                                                <th class="span2"><span class="line"></span>购买商品</th>
						<th class="span2"><span class="line"></span>付款金额</th>
						<th class="span2"><span class="line"></span>收货地址</th>
						<th class="span2"><span class="line"></span>订单状态</th>
						<th class="span2"><span class="line"></span>操作</th>
					</tr>
					</thead>
					<form action="/shop-order/batch" method="post" name="batch">
						<tbody>
						<?php if($list):?>
							<?php foreach ($list as $item):?>
								<!-- row -->
								<tr class="first">
                                    <td class="order_no"><?php echo $item['order_no']?></td>
									<td class="ocreate_time"><?php echo date('Y-m-d G:i:s',$item['ocreate_time'])?></td>
									<td class="opay_time"><?php echo empty($item['opay_time']) ? '':date('Y-m-d G:i:s',$item['opay_time'])?></td>
									<td class="mobile"><?php echo $item['mobile']?></td>
                                                                        <td class="mobile"><?php echo $item['nickname']?></td>
                                                                        <td class="mobile"><?php echo $item['product_name']?>(×<?php echo $item['product_num']?>)</td>
                                                                        <td class="mobile"><?php echo $item['pay_amount']?></td>									
									<td class="address"><?php echo $item['province_name']. $item['city_name']. $item['district_name']. $item['address_name']?></td>
									<td class="pay_status"><?php echo $item['order_status_name'] ?></td>
									<td class="options">
                                            <button type="button" class=" btn-flat primary" onclick="window.location.href='/n-shop-order/orderinfo?id=<?php echo $item['order_id']?>'">详细</button></li>
									</td>
								</tr>
							<?php endforeach;?>
						<?php endif;?>
						</tbody>
					</form>
				</table>
			</div>
		</div>
		<!-- end products table -->
	</div>
	<div class="pagination pull-right">
		<?php echo $pagination;?>
	</div>
<!--Edited by ysy Start-->
	<script type="text/javascript">
		$(function () {
			<!--表格标题点击排序-->
			$("th.clickable_pay_stime").click(function () {
				var param=$(this).data("param" );
				if (!$("th.clickable_pay_stime .icon.icon-chevron-down").length>0) {
					$(this).find(".icon").addClass("icon-chevron-down").removeClass("icon-chevron-up");
					var  $order_status = $('select[name="order_status"]').val();
					var  $start_time = $('input[name="start_time"]').val();
					var  $end_time = $('input[name="end_time"]').val();
					var  $pay_start_time = $('input[name="pay_start_time"]').val();
					var  $pay_end_time = $('input[name="pay_end_time"]').val();
					var  $mobile = $('input[name="mobile"]').val();
					var  $url = '/n-shop-order/index?order_status='+$order_status+"&sort_pay_time=desc"+"&pay_start_time="+$pay_start_time+"&pay_end_time="+$pay_end_time+"&start_time="+$start_time+"&end_time="+$end_time+"&mobile="+$mobile;
					$.ajax({
						type:'get',
						url:$url,
						cache:false,
						dataType:'json',
						success:function(data){
//						window.location.reload($url);//刷新当前页面.
							location.href =$url;
						},
						error:function(){
//						window.location.reload($url);//刷新当前页面.
							location.href =$url;
						}
					});
				}
				else {
					$(this).find(".icon").addClass("icon-chevron-up").removeClass("icon-chevron-down");
					var  $order_status = $('select[name="order_status"]').val();
					var  $start_time = $('input[name="start_time"]').val();
					var  $end_time = $('input[name="end_time"]').val();
					var  $pay_start_time = $('input[name="pay_start_time"]').val();
					var  $pay_end_time = $('input[name="pay_end_time"]').val();
					var  $mobile = $('input[name="mobile"]').val();
					var  $url = '/n-shop-order/index?order_status='+$order_status+"&sort_pay_time=asc"+"&pay_start_time="+$pay_start_time+"&pay_end_time="+$pay_end_time+"&start_time="+$start_time+"&end_time="+$end_time+"&mobile="+$mobile;
					$.ajax({
						type:'get',
						url:$url,
						cache:false,
						dataType:'json',
						success:function(data){
//						window.location.reload($url);//刷新当前页面.
							location.href =$url;
						},
						error:function(){
//						window.location.reload($url);//刷新当前页面.
							location.href =$url;
						}
					});
				}
			});

			/*
			 时间排序事件
			 */
			$("th.clickable_time").click(function () {
				var param=$(this).data("param" );
				if (!$("th.clickable_time .icon.icon-chevron-down").length>0) {
					$(this).find(".icon").addClass("icon-chevron-down").removeClass("icon-chevron-up");
					var  $order_status = $('select[name="order_status"]').val();
					var  $start_time = $('input[name="start_time"]').val();
					var  $end_time = $('input[name="end_time"]').val();
					var  $pay_start_time = $('input[name="pay_start_time"]').val();
					var  $pay_end_time = $('input[name="pay_end_time"]').val();
					var  $mobile = $('input[name="mobile"]').val();
					var  $url = '/n-shop-order/index?order_status='+$order_status+"&sort_time=desc"+"&pay_start_time="+$pay_start_time+"&pay_end_time="+$pay_end_time+"&start_time="+$start_time+"&end_time="+$end_time+"&mobile="+$mobile;
					$.ajax({
						type:'get',
						url:$url,
						cache:false,
						dataType:'json',
						success:function(data){
//						window.location.reload($url);//刷新当前页面.
							location.href =$url;
						},
						error:function(){
//						window.location.reload($url);//刷新当前页面.
							location.href =$url;
						}
					});
				}
				else {
					$(this).find(".icon").addClass("icon-chevron-up").removeClass("icon-chevron-down");
					var  $order_status = $('select[name="order_status"]').val();
					var  $start_time = $('input[name="start_time"]').val();
					var  $end_time = $('input[name="end_time"]').val();
					var  $pay_start_time = $('input[name="pay_start_time"]').val();
					var  $pay_end_time = $('input[name="pay_end_time"]').val();
					var  $mobile = $('input[name="mobile"]').val();
					var  $url = '/n-shop-order/index?order_status='+$order_status+"&sort_time=asc"+"&pay_start_time="+$pay_start_time+"&pay_end_time="+$pay_end_time+"&start_time="+$start_time+"&end_time="+$end_time+"&mobile="+$mobile;
					$.ajax({
						type:'get',
						url:$url,
						cache:false,
						dataType:'json',
						success:function(data){
							location.href =$url;
						},
						error:function(){
							location.href =$url;
						}
					});
				}
			});
                        $("#daochu").click(function () {
			$('#tag').val(2);
			document.forms['search'].submit();
			$('#tag').val(1);
		      });
                
		});
	</script>
	<style>
		th{
			text-align: center !important;
		}
        table td{
            text-align: center !important;
        }
		table th span.line{
			left:0 !important;
		}
		th.clickable_pay_stime{
			cursor:pointer;
		}
		th.clickable_time{
			cursor:pointer;
		}
		th.clickable_pay_stime .icon{
			margin-left:10px;
		}
		th.clickable_time .icon{
			margin-left:10px;
		}
	</style>
<!--Edited by ysy End-->
</div>